package com.hdu.other.dp.maxSubArraySum;

public class lc198 {
    class Solution {
        public int rob(int[] nums) {
            int len = nums.length;
            if (len == 1)
            {
                return nums[0];
            }
            if (len == 2)
            {
                return Math.max(nums[0], nums[1]);
            }
            int a = nums[0];
            int b = Math.max(nums[0], nums[1]);
            for (int i = 2; i < len; i++)
            {
                int cur = Math.max(a + nums[i], b);
                a = b;
                b = cur;
            }
            return b;
        }
    }
}
